﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Cosmetic.Logic;
using System.Collections;

namespace WebApp
{
    public partial class shrh : System.Web.UI.MasterPage
    {
        ProductManager pm = new ProductManager();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (null == Session["SignInUser"])
                {
                    //this.Label1.Text = "欢迎您，您尚未";
                }
                else
                {
                    this.lbWelcome.Text = "欢迎您，" + Session["UserName"].ToString() + "!";
                    //this.Label1.Text = "欢迎您，" + Session["tel"].ToString() + "!";
                    this.LinkBtnLogin.Text = "退出";
                    //this.lindenglu.Text = "退出";
                    this.LinkBtnRegister.Visible = false;
                    //this.Linkzhuce.Visible = false;
                }
                if (Session["buycart"]!=null)
                {
                    LinkBtnShopCart.Text = ((Hashtable)Session["buycart"]).Count.ToString();
                }
                this.Repeater1.DataSource = pm.GetHotKeyWord();
                this.Repeater1.DataBind();
            }
        }
        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            Response.Redirect("~/Product/Search." + this.TextBox1.Text.Trim()+ ".htm");
        }
        
        protected void LinkBtnRegister_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/Register.htm");
        }
        protected void LinkBtnLogin_Click(object sender, EventArgs e)
        {
            if (LinkBtnLogin.Text == "退出")
            {
                Session.Clear();
                LinkBtnLogin.Text = "登录";
                this.LinkBtnRegister.Visible = true;
                Response.Redirect("~/Home.htm");
            }
            else
            {
                Response.Redirect("~/Login.htm");
            }
        }
    }
}